package com.atstudy.headline.web.app.controller.users;

import com.atstudy.headline.entity.Contents;
import com.atstudy.headline.entity.Users;
import com.atstudy.headline.result.Result;
import com.atstudy.headline.web.app.service.UserFollowsService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/app/user")
public class AppUserFollowController {

    @Autowired
    private UserFollowsService userFollowsService;

    /**
     * 粉丝列表
     * @param userId
     * @param current
     * @param size
     * @return
     */
    @GetMapping("/getFollower/{userId}")
    public Result<IPage<Users>> getFollower(
            @PathVariable Integer userId,
            @RequestParam(required = false, defaultValue = "1") Integer current,
            @RequestParam(required = false, defaultValue = "6") Integer size) {

        IPage<Users> page = new Page<>(current, size);
        IPage<Users> result = userFollowsService.getFollower(page,userId);
        return Result.ok(result);
    }

    /**
     * 关注列表
     * @param userId
     * @param current
     * @param size
     * @return
     */
    @GetMapping("/getFollowing/{userId}")
    public Result<IPage<Users>> getFollowing(
            @PathVariable Integer userId,
            @RequestParam(required = false, defaultValue = "1") Integer current,
            @RequestParam(required = false, defaultValue = "6") Integer size) {

        IPage<Users> page = new Page<>(current, size);
        IPage<Users> result = userFollowsService.getFollowing(page,userId);
        return Result.ok(result);
    }
}
